package com.ktgj.flight.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ktgj.flight.domain.vo.FinanceConsignPymtLogVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.flight.domain.FinanceConsignPymtLog;
import com.ktgj.flight.service.IFinanceConsignPymtLogService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 财务机票代收交易日志Controller
 * 
 * @author ruoyi
 * @date 2022-06-15
 */
@RestController
@RequestMapping("/log")
public class FinanceConsignPymtLogController extends BaseController
{
    @Autowired
    private IFinanceConsignPymtLogService financeConsignPymtLogService;

    /**
     * 查询财务机票代收交易日志列表
     */
    @PreAuthorize(hasPermi = "system:log:list")
    @GetMapping("/list")
    public TableDataInfo list(FinanceConsignPymtLog financeConsignPymtLog)
    {
        startPage();
        List<FinanceConsignPymtLog> list = financeConsignPymtLogService.selectFinanceConsignPymtLogList(financeConsignPymtLog);
        return getDataTable(list);
    }

    /**
     * 导出财务机票代收交易日志列表
     */
    @PreAuthorize(hasPermi = "system:log:export")
    @Log(title = "财务机票代收交易日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FinanceConsignPymtLog financeConsignPymtLog) throws IOException
    {
        List<FinanceConsignPymtLog> list = financeConsignPymtLogService.selectFinanceConsignPymtLogList(financeConsignPymtLog);
        ExcelUtil<FinanceConsignPymtLog> util = new ExcelUtil<FinanceConsignPymtLog>(FinanceConsignPymtLog.class);
        util.exportExcel(response, list, "财务机票代收交易日志数据");
    }

    /**
     * 获取财务机票代收交易日志详细信息
     */
    @PreAuthorize(hasPermi = "system:log:query")
    @GetMapping(value = "/{financeConsignPymtLogId}")
    public AjaxResult getInfo(@PathVariable("financeConsignPymtLogId") Long financeConsignPymtLogId)
    {
        return AjaxResult.success(financeConsignPymtLogService.selectFinanceConsignPymtLogById(financeConsignPymtLogId));
    }

    /**
     * 新增财务机票代收交易日志
     */
    @PreAuthorize(hasPermi = "system:log:add")
    @Log(title = "财务机票代收交易日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FinanceConsignPymtLog financeConsignPymtLog)
    {
        return toAjax(financeConsignPymtLogService.insertFinanceConsignPymtLog(financeConsignPymtLog));
    }

    /**
     * 修改财务机票代收交易日志
     */
    @PreAuthorize(hasPermi = "system:log:edit")
    @Log(title = "财务机票代收交易日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FinanceConsignPymtLog financeConsignPymtLog)
    {
        return toAjax(financeConsignPymtLogService.updateFinanceConsignPymtLog(financeConsignPymtLog));
    }

    /**
     * 删除财务机票代收交易日志
     */
    @PreAuthorize(hasPermi = "system:log:remove")
    @Log(title = "财务机票代收交易日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{financeConsignPymtLogIds}")
    public AjaxResult remove(@PathVariable Long[] financeConsignPymtLogIds)
    {
        return toAjax(financeConsignPymtLogService.deleteFinanceConsignPymtLogByIds(financeConsignPymtLogIds));
    }

    /**
     * 支付记录录入
     * */
    @PostMapping("/saveFinanceConsignPymtLog")
    public AjaxResult saveFinanceConsignPymtLog(@RequestBody FinanceConsignPymtLogVo financeConsignPymtLogVo) {
        int i = financeConsignPymtLogService.saveFinanceConsignPymtLog(financeConsignPymtLogVo);
        if (i > 0){
            return AjaxResult.success("录入成功");
        }
        else {
            return AjaxResult.success("录入失败");
        }
    }
}
